Link to this headingWeb Sockets
- A heartbeat is built in to the protocol
- Uses the wss:// or ws:// schema
- Parsing the schema is weird Schema RFC
- Do not tunnel other services though this because it would allow services to preform XSS attacks
- Websockets do not respect CORS
Link to this headingHandshake
Initial Upgrade Request:
? HTTP/1.1
Initial Upgrade Response:
HTTP/1.1
Link to this headingWebSocket-Key
The Sec-WebSocket-Accept value is generated from the initial key sent from the client and a static value in the RFC.
Generating the Sec-WebSocket-Accept:
= b
= b
=
#b'H82Hn1AbYRO3N7uzo6yysC0KdM0='
Link to this headingURL Parsing
- Web Socket URLs parse different from HTTP URLs
#ParseResult(scheme='wss', netloc='foo', path='/?bar=baz', params='', query='', fragment='')
F:\Memory\Web Exploitation\Technologies\Web Sockets.md
Link to this headingAuthentication/Authorization
- There is no authentication in the Protocol. The application must use TLS, [HTTP Headers](/Web Exploitation/HTTP Headers.md) or Cookies to authenticate.
- Need to Connect the Client IP to the account that requested the Websocket Upgrade.
Link to this headingOrigin Header
- Not restrained by Cross Origin Policy
- Origin is sent in the Upgrade request
- Make sure that the Server limits the allowed origins by checking the Origin Header in the Upgrade request
- If this is not set then an attacker can so Cross Origin WebSockets. This includes sending request and getting responses responses
Link to this headingFraming
Link to this headingTunneling
Link to this headingSecurity
Link to this headingAuthentication/Authorization
Access Control:
Link to this headingCross-Site WebSocket Hijacking (CSWSH)
Websockets are not restricted by Cross Origin Policy. You can make a Websocket from another domain and this will send cookies alongside with it. This is up to the server to restrict.
Example CSWSH Request:
? HTTP/1.1
Example CSWSH Response
HTTP/1.1
Link to this headingTesting
Web Socket Tester:
WebSocket Tester
WebSocket Tester
Target:
Connect
Disconnect
Message:
Send
Output:
Testing Script:
Testing Script2: